# @FileName  : screen.py
# @Time      : 2025/3/6 07:30
# @Author    : LuZhaoHui
# @Software  : PyCharm

from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *


def showBox(obj, msg, title='提示'):
    QMessageBox.about(obj, title, '     %s     ' % msg)


def showBoxYes(obj, msg, title='提示'):
    reply = QMessageBox.question(obj,
                                 title,
                                 '     %s     ' % msg,
                                 QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
    if reply == QMessageBox.Yes:
        return True
    return False


def showLabelImage(area, label, name, self):
    img = QImage()
    img.load(name)
    if self:
        w = area.width()
        h = area.height()
        new_img = img.scaled(w, h, Qt.KeepAspectRatio)
        label.setPixmap(QPixmap.fromImage(new_img, flags=Qt.AutoColor))
    else:
        label.setPixmap(QPixmap.fromImage(img,flags=Qt.AutoColor))


def setComboBoxHeight(combo, h):
    combo.setStyleSheet("QAbstractItemView::item{height: %dpx;}" % h)
    combo.setView(QListView())
